<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "hl_resource_classes".
 *
 * @property int $id ID
 * @property int $pid 父id
 * @property string $title 分类名称
 * @property int $sort 排序
 * @property int $status 状态 1启用,0禁用
 * @property string $add_time 创建时间
 * @property string $created_at 创建时间
 * @property string $updated_at 修改时间
 * @property string $deleted_at 删除时间
 */
class ResourceClasses extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'hl_resource_classes';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title'], 'unique'],
            [['pid', 'sort', 'status'], 'integer'],
            [['add_time'], 'required'],
            [['add_time', 'created_at', 'updated_at', 'deleted_at'], 'safe'],
            [['title'], 'string', 'max' => 64],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '序号',
            'pid' => '分类级别',
            'title' => '分类名称',
            'sort' => '排序',
            'status' => '状态',
            'add_time' => '添加时间',
            'created_at' => '添加时间',
            'updated_at' => '修改时间',
            'deleted_at' => 'Deleted At',
        ];
    }

    /**
     * 场景
     */
    const SCENARIOS_CATE_CU = 'create_update';

    public function scenarios()
    {
        $scenarios = [
            self::SCENARIOS_CATE_CU => ['pid', 'title', 'sort']];
        return array_merge(parent::scenarios(), $scenarios);
    }
}
